package com.bwysj.loan.controller;

//返回值
//分页工具类

import com.bwyjs.common.utils.PageUtils;
import com.bwyjs.common.utils.R;
import com.bwysj.loan.entity.SubjectTypeEntity;
import com.bwysj.loan.service.SubjectTypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 标的类型
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-07-20 09:46:48
 */
@RestController
@RequestMapping("generator/subjecttype")
public class SubjectTypeController {
    @Autowired
    private SubjectTypeService subjectTypeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:subjecttype:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = subjectTypeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:subjecttype:info")
    public R info(@PathVariable("id") Integer id){
		SubjectTypeEntity subjectType = subjectTypeService.getById(id);

        return R.ok().put("subjectType", subjectType);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:subjecttype:save")
    public R save(@RequestBody SubjectTypeEntity subjectType){
		subjectTypeService.save(subjectType);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:subjecttype:update")
    public R update(@RequestBody SubjectTypeEntity subjectType){
		subjectTypeService.updateById(subjectType);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:subjecttype:delete")
    public R delete(@RequestBody Integer[] ids){
		subjectTypeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
